import { defineStore } from "pinia";
import { Message, UserMessage } from "~~/types";

interface userMessageStoreInterface {
  selectUserId: string;
  userMessage: UserMessage | null;
}

export const useUserMessageList = defineStore("userMessage", {
  state: (): userMessageStoreInterface => {
    return {
      selectUserId: "",
      userMessage: null,
    };
  },
  getters: {
    getUserMessage: (state) => state.userMessage,
    getGetSelectUserId: (state) => state.selectUserId,
  },
  actions: {
    setUserMessage(value: UserMessage) {
      this.userMessage = value;
    },
    setMessageListItem(value: Message) {
      this.userMessage?.messages.push(value);
    },
    setSelectUserId(value: string) {
      this.selectUserId = value;
    },
  },
});
